package com.zwb.demo.easyweb.modules.config.controller;


import com.zwb.demo.easyweb.common.entity.response.ResponseResult;
import com.zwb.demo.easyweb.modules.config.service.GenTemplateFileService;
import com.zwb.demo.easyweb.modules.config.vo.GenTemplateFileVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(value = "模板文件管理接口" ,description = "模板文件管理接口")
public class GenTemplateFileController {


    private final GenTemplateFileService templateFileService;

    @Autowired
    public GenTemplateFileController(GenTemplateFileService templateFileService) {
        this.templateFileService = templateFileService;
    }

    @GetMapping("/config/templateFile")
    @ApiOperation(value = "查询所有模板文件")
    public ResponseResult findAll(){
        return templateFileService.findAll();
    }

    @GetMapping("/config/template/{uuid}/templateFiles")
    @ApiOperation(value = "查询所有模板文件")
    public ResponseResult findAllByTemplateId(@PathVariable String uuid){
        return templateFileService.findAllByTemplateId(uuid);
    }

    @PutMapping("/config/templateFile")
    @ApiOperation(value = "新增或修改模板文件")
    public ResponseResult addOne(@RequestBody GenTemplateFileVO vo){
        return templateFileService.saveOne(vo);
    }

    @DeleteMapping("/config/templateFile/{uuid}")
    @ApiOperation(value = "删除模板文件")
    public ResponseResult deleteOne(@PathVariable String uuid){
        return templateFileService.deleteOne(uuid);
    }

}
